package com.wb.code09集合;

import java.util.AbstractList;
import java.util.Arrays;
import java.util.LinkedList;

/**
 * @author 黄衡熙
 * @version 1.0
 */
public class Test08_LinkedList {
    public static void main(String[] args) {
        //定义方式一
        LinkedList<String> list = new LinkedList<String>();
        //定义方式二
        LinkedList list1 = new LinkedList(Arrays.asList(1,3,4));
        //可以使用List的相关方法
        list.add("admin");
        list.add("jack");
        list.add("tom");
        list.add("wang");
        System.out.println(list);

        //队列相关方法
        //addForst():在首部添加一个元素
        list.addFirst("admin");
        list.addLast("jack");
        System.out.println(list);

        System.out.println(list.getFirst());
        System.out.println(list.getLast());

        list.removeFirst();
        System.out.println(list);
        list.removeLast();
        System.out.println(list);

        System.out.println(list.peekFirst());
        System.out.println(list.peekLast());

        System.out.println(list.pollFirst());
        System.out.println(list.pollLast());

    }
}
